<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/11/22
 * Time: 22:24
 */
require("Include/conn.php");
if(isset($_COOKIE['user_id'])&&is_numeric($_COOKIE['user_id'])){
    $user_id = $_COOKIE['user_id'];
//search in database
    $sql = "SELECT * FROM `pw_user` WHERE `user_id`='$user_id';";
    $result = mysqli_query($link,$sql);
    $result_array = mysqli_fetch_array($result);
    $user_name = $result_array['user_name'];
    $user_email = $result_array['user_email'];
}
else{
    header('location: http://localhost/mark/login.php');
}
?>

<head>
    <!-- 新 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="./dist/css/bootstrap.min.css">

    <!-- 可选的Bootstrap主题文件（一般不用引入） -->
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap-theme.min.css">

    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="http://cdn.bootcss.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
    <!-- 引入 Bootstrap -->
    <link href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">
    <!-- Bootstrap core CSS -->
    <link href="dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Custom styles for this template -->
    <link href="navbar.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="dist/css/bootstrap.min.css">
    <script src="dist/jquery-3.1.1.js"></script>
    <script src="dist/js/bootstrap.min.js"></script>
</head>

<body background="img/bg.png">

<div class="container-fluid">
    <div class="row-fluid">
        <div class="span2">
            <img alt="140x140" src="img/logo.jpg" />
        </div>
        <div class="span6">
            <form class="form-search">
                <input class="input-medium search-query" type="text" /> <button type="submit" class="btn">查找</button>
            </form>
        </div>

        <div class="span4">
        </div>
    </div>
    <div>
        <?php
        if(!empty($_COOKIE['user_id'])) {
            $sql = "SELECT `user_name` FROM `pw_user` WHERE `user_id`=" . $_COOKIE['user_id'];
            $user_name = mysqli_fetch_array(mysqli_query($link, $sql))['user_name'];
            echo "<h3 style=\"color:blue \">
								$user_name   欢迎你！
							</h3>
						";
        }
        ?>
    </div>
    <div class="row-fluid">
        <div class="span8">
            <ul class="nav nav-pills">
                <li class="active">
                    <a href="index.php">首页</a>
                </li>
                <li>
                    <a href="#">留言</a>
                </li>
                <li>
                    <a href="infopage.php">修改个人资料</a>
                </li>
                <li>
                    <?php
                    ?>
                    <a href="uploadpage.php">上传</a>
                </li>
                <li class="dropdown pull-right">
                    <a class="dropdown-toggle" data-toggle="dropdown" href="#"></a>
                    <ul class="dropdown-menu">
                        <li>
                            <a href="#">操作</a>
                        </li>
                        <li>
                            <a href="#">设置栏目</a>
                        </li>
                        <li>
                            <a href="#">更多设置</a>
                        </li>
                        <li class="divider">
                        </li>
                        <li>
                            <a href="#">分割线</a>
                        </li>
                    </ul>
                </li>
            </ul>
            <h2>
                <em><strong>我的作品</strong></em>
            </h2>
            <?php
                include ("picprint.php");
                $sql = "SELECT `pic_id` FROM `pw_pic` WHERE `pic_userid`=$user_id AND `pic_stat`=1 ORDER BY `pic_time`;";
                $result = mysqli_query($link,$sql);

                for($i=0;$i<8;$i++){
                    $row[$i]=mysqli_fetch_row($result);
                }
                if($row[0]==null){
                    echo "您还没有发布过作品";
                }
                else{
                    rowpic_user($row[0][0],$row[1][0],$row[2][0],$row[3][0]);
                    rowpic_user($row[4][0],$row[5][0],$row[6][0],$row[7][0]);
                }
            ?>

        </div>
        <div class="span4">
            <h2>
                <em><strong>好友列表</strong></em>
            </h2>
            <ol>
                <li>
                    新闻资讯
                </li>
                <li>
                    体育竞技
                </li>
                <li>
                    娱乐八卦
                </li>
                <li>
                    前沿科技
                </li>
                <li>
                    环球财经
                </li>
                <li>
                    天气预报
                </li>
                <li>
                    房产家居
                </li>
                <li>
                    网络游戏
                </li>
            </ol>
        </div>
    </div>
    <div class="row-fluid">
        <div class="span12">
        </div>
    </div>
</div>

</body>